<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%
	String path = request.getContextPath();
	String basepath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	System.out.println("basepath:"+basepath);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basepath %>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery-1.8.3.js" ></script>
<style>
	.splitinfo{
		font-size: 13px;
		color:gray;
	}
</style>
<script type="text/javascript">

$(function(){
	$("#tb tr:gt(0):odd").attr("bgcolor","gray");
});



function gopage(nowpage){
	
	var totalpage = parseInt(document.getElementById("totalpage").value);
	
	if(parseInt(nowpage)<=0){
		alert("已经是第一页了");
	}else if(parseInt(nowpage)>totalpage){
		alert("已经是最后一页了");
	}else{
		splitform.cp.value = nowpage;
		splitform.submit();
	}
}
</script>
</head>
<body>
<h3>这里是main.jsp页面</h3>
<a href="bc/add" >新增</a>
<table id="tb" border="1" width="100%" cellspacing="0" >
	<tr>
		<th>编号</th>
		<th>书名</th>
		<th>出版社</th>
		<th>价格</th>
		<th>出版日期</th>
		<th>作者</th>
		<th>简介</th>
		<th>操作</th>
	</tr>
	
	<c:forEach items="${booklist }" var="bl" varStatus="b" >
	<tr>
		<td>${bl.bookid }</td>
		<td>
			<a href="bc/findbyid?bookid=${bl.bookid }" >${bl.bookName }</a>
		</td>
		<td>${bl.publicDept }</td>
		<td>
			<fmt:formatNumber value="${bl.bookPrice }" pattern="￥00.00" ></fmt:formatNumber>
		</td>
		<td>
			<fmt:formatDate value="${bl.publicDate }" pattern="yyyy-MM-dd" />
		</td>
		<td>${bl.bookAuth }</td>
		<%-- <td>${bl.summary.substring(0,15) }...</td> --%>
		<td>
			${fn:substring(bl.summary,0,15) }${fn:length(bl.summary)>15?"...":"" }
		</td>
		<td></td>
	</tr>
	</c:forEach>
	
	
</table>

<form name="splitform" action="firstpage" method="post" >
	<input type="hidden" value="${totalpage }" name="totalpage" id="totalpage" />
	<input type="hidden" value="${count }" name="count" id="count" />
	<input type="hidden" value="${cp }" name="cp" id="cp" />
	<input type="hidden" value="${ps }" name="ps" id="ps" />
	
	
	<input type="button" value="首页" onclick="gopage('1');" />
	<input type="button" value="上一页" onclick="gopage('${cp-1}');" />
	
	<a href="javascript:void(0);" >${cp }</a>
	
	<input type="button" value="下一页" onclick="gopage('${cp+1}');" />
	<input type="button" value="尾页" onclick="gopage('${totalpage}');" />
	<span class="splitinfo">
		共计有<b>${count }</b>行数据，分为<b>${totalpage }</b>页，每页显示<b>${ps }</b>行,当前是第<b>${cp }</b>页
	</span>
</form>

</body>
</html>